<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="请输入1-100的整数">
<input type="button" value="猜一猜" onclick="f1()">
<div id="d">结果</div><br>
<script>
  let x=parseInt(Math.random()*100+1);
  console.log(x);
  let d=document.querySelector("#d");
  let num=0;
  function f1(){
      num++;
      let i = document.querySelector("input");
      b=confirm("hhhhhh");
      alert("11")
      p=prompt("几点下课");
      if (i.value > 100 || i.value < 0 || isNaN(i.value)) {
        d.innerText = "输入错误";
        return;
      }
      if (i.value > x) {
        d.innerText = "猜大了猜了" + num + "次"
      } else if (i.value < x) {
        d.innerText = "猜小了猜了" + num + "次"
      } else {
        d.innerText = "猜对了,猜了" + num + "次";
        x=parseInt(Math.random()*100+1);
        console.log(x);
        num=0;
      }
      i.value = ""

  }
</script>
</body>
</html>